package com.example.demo_job.service.impl;

import com.example.demo_job.entity.RecruitSeeker;
import com.example.demo_job.mapper.RecruitMapper;
import com.example.demo_job.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecruitServiceimpl implements RecruitService {
    @Autowired
    private RecruitMapper recruitMapper;
    @Override
    public List<RecruitSeeker> QueryRecruit(int pid) {
        List<RecruitSeeker> list = recruitMapper.QueryRecruit(pid);
        return list;
    }

    @Override
    public void UpdateFlag(int sid, int pid,boolean flag) {
        recruitMapper.UpdateFlag(sid, pid,flag);
    }

    @Override
    public List<RecruitSeeker> QueryRecruitByEdu(int pid, int sedu) {
        List<RecruitSeeker> list = recruitMapper.QueryRecruitByEdu(pid,sedu);
        return list;
    }

    @Override
    public boolean judgeadd(int pid) {
        int enumber=recruitMapper.findenumberBypid(pid);
        int anumber=recruitMapper.findanumberBypid(pid);
        if(enumber<=anumber) return false;
        return true;
    }

    @Override
    public void UpdatePositionNumBypid(int pid, boolean flag) {
        if(flag) {
            //-1
            recruitMapper.updatePositionNumBypid(pid,-1);
        }
        else {
            //+1
            recruitMapper.updatePositionNumBypid(pid,1);
        }
    }
}
